package com.xiong.word.model;

import com.xiong.word.WordEngine;
import com.xiong.word.ext.XWPFTableRowCallback;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.apache.poi.xwpf.usermodel.XWPFTableRow;

import java.util.List;

public class TableModel {

    private XWPFTable table;

    private WordEngine wordEngine;

    public TableModel(XWPFTable table,WordEngine wordEngine){
        this.table=table;
        this.wordEngine=wordEngine;
    }

    public void forEachRow(XWPFTableRowCallback rowCallback){
        List<XWPFTableRow> rows = table.getRows();
        for (int i = 0; i < rows.size() ; i++) {
            XWPFTableRow row=rows.get(i);
            XWPFTableRowModel model=new XWPFTableRowModel(this.table,row);
            rowCallback.dealXWPFTableRow(i,model);
        }
    }

    public WordEngine end(){
        return this.wordEngine;
    }
}
